package com.penjin.android.activity.kaoqin;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

import com.penjin.android.R;
import com.penjin.android.activity.gongzuo.PenjinBaobiaoActivity;
import com.penjin.android.adapter.GridAdapter;
import com.penjin.android.view.TitleBarView;

import java.util.ArrayList;

/**
 * Created by fengjw on 2016/3/14.
 */
public class KaoqinTongjiActivity extends Activity {

    private TitleBarView titleBarView;
    private TextView centerView;


    public String[] str = {"公司荣誉墙", "迟到饼图", "管理报表", "缺勤记录", "今日迟到榜", "每月迟到榜", "请假/调休", "值班/加班"};
    private GridView gv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_activity_penjin_tongji);

        initTitleBar();
        initView();

    }

    private void initView() {

        //gridview
        final ArrayList<String> mListname = new ArrayList<String>();
        for (int i = 0; i < str.length; i++) {
            mListname.add(str[i]);
        }
        gv = (GridView) findViewById(R.id.gridview);

        //Drawable drawable = getResources().getDrawable(R.drawable.shape);
        gv.setAdapter(new GridAdapter(this, mListname));
        // gv.setSelector(drawable);

        gv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Intent intent;
                switch (i) {
                    case 0:
                        intent = new Intent(KaoqinTongjiActivity.this, RongyuBangActivity.class);
                        startActivity(intent);
                        break;
                    case 1:
                        intent = new Intent(KaoqinTongjiActivity.this, LateChartActivity.class);
                        startActivity(intent);
                        break;
                    case 2:
                        intent = new Intent(KaoqinTongjiActivity.this, PenjinBaobiaoActivity.class);
                        startActivity(intent);
                        break;
                    case 3:
                        intent = new Intent(KaoqinTongjiActivity.this, NoSignKaoqinActivity.class);
                        intent.putExtra("title", str[i]);
                        startActivity(intent);
                        break;
                    case 4:
                        intent = new Intent(KaoqinTongjiActivity.this, KaoqinLateActivity.class);
                        intent.putExtra("title", str[i]);
                        startActivity(intent);
                        break;
                    case 5:
                        intent = new Intent(KaoqinTongjiActivity.this, KaoqinLateActivity.class);
                        intent.putExtra("title", str[i]);
                        startActivity(intent);
                        break;
                    case 6:
                        intent = new Intent(KaoqinTongjiActivity.this, NoSignKaoqinActivity.class);
                        intent.putExtra("title", str[i]);
                        startActivity(intent);
                        break;
                    case 7:
                        intent = new Intent(KaoqinTongjiActivity.this, NoSignKaoqinActivity.class);
                        intent.putExtra("title", str[i]);
                        startActivity(intent);
                        break;
                }


            }
        });

    }

    private void initTitleBar() {

        centerView = (TextView) findViewById(R.id.titlebar_center_text);
        centerView.setText("考勤统计");
        //left
        ImageView leftView = (ImageView) findViewById(R.id.titlebar_left_img);
        leftView.setImageResource(R.drawable.ease_back);
        //right
        ImageView rightView = (ImageView) findViewById(R.id.titlebar_right_img);
        rightView.setVisibility(View.GONE);

        TextView rightText = (TextView) findViewById(R.id.titlebar_right_tv);
        //rightText.setVisibility(View.VISIBLE);
        rightText.setText(R.string.kaopin_update);

        titleBarView = (TitleBarView) findViewById(R.id.titleBar);

        titleBarView.setTitleBarListener(new TitleBarView.TitleBarListener() {
            @Override
            public void left(View view) {
                finish();
            }

            @Override
            public void center(View view) {

            }

            @Override
            public void right(View view) {

            }
        });
    }

}
